package simple.alert;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import simple.alert.message.AlarmLevelMessage;
import simple.alert.rule.condition.AboveConditionImpl;
import simple.alert.rule.condition.BreakConditionDecorator;
import simple.alert.rule.condition.EqualConditionImpl;
import simple.alert.rule.condition.ICondition;
import simple.alert.rule.expression.Expression;
import simple.alert.rule.group.GroupOperator;
import simple.alert.rule.group.OrGroupOperator;

public class AlertSystemMain4 {

	public static void main(String[] strings) {

		List<ICondition> conditionList = new ArrayList<>();

		conditionList.add(new EqualConditionImpl(2));
		conditionList.add(
				new BreakConditionDecorator(new AboveConditionImpl(4)));
		
		AlarmLevelMessage alarmLevelMessage = AlarmLevelMessage.WARNING;
		GroupOperator groupOperator = new OrGroupOperator();

		Expression expression = 
				new Expression(groupOperator, conditionList, alarmLevelMessage);
		
		try {
			InputStream is = System.in;
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String inputStr = br.readLine();
            String[] inputs =inputStr.split(",");
            System.out.println(Stream.of(inputs).map(x -> expression.eval(Long.parseLong(x)).toString()).collect(Collectors.joining(",")));
        } catch (IOException e) {
            e.printStackTrace();
        }

	}

}
